﻿@using Website.CRUDServices
@using Location = Website.Models.Domain.Location
@using Region = Website.Models.Domain.Region
@model Matchmaking
@{
    this.ViewBag.Title = "Matchmaking";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";
    var Regions = this.ViewData["Regions"] as List<Region>;
    var Funds = this.ViewData["Funds"] as List<Fund>;
    var PartnerTypes = this.ViewData["PartnerTypes"] as List<MatchmakingPartnerType>;
    var Projects = this.ViewData["Projects"] as List<Project>;
    var Profiles = this.ViewData["Profiles"] as List<Profile>;
    var Locations = this.ViewData["Locations"] as List<Location>;
    var MatchMake = Model as Matchmaking;
    var Partner = this.ViewData["Partners"] as MatchmakingPartner;
    var partnerID = Guid.Empty;
    if (Partner != null && Partner.ID != null && Partner.ID != Guid.Empty)
    {
        partnerID = Partner.ID;
    }
    // errorhandling
    var errorMsg = new HtmlString(string.Empty);
    if (this.ViewData["ErrorMessage"] != null)
    {
        errorMsg = this.ViewData["ErrorMessage"] as HtmlString;
    }

}

@Html.Partial("~/Views/_Shared/LogView.cshtml", Model.ID)

@*// ********************Matchmaking**********************@

@*// name*@
<fieldset class="chosenFields">
    <legend>Navn</legend>
    @MatchMake.Name
</fieldset>

@*// date*@
<fieldset class="chosenFields">
    <legend>Dato</legend>
    @if (MatchMake.Date.HasValue)
    {
        @MatchMake.Date.Value.ToShortDateString()}
</fieldset>

@*// location*@
<fieldset class="chosenFields">
    <legend>Lokation</legend>

    @foreach (Location loc in Locations.OrderBy(x => x.Name))
    {

        if (loc.ID == MatchMake.Location)
        {
        @loc.Name <br />
        }
    }

</fieldset>

@*// ownerProjects chooser*@
<fieldset class="chosenFields">
    <legend>Alle projekter tilknyttet</legend>

    @foreach (Project proj in Projects.Where(x => (MatchMake.OwnerProjects ?? new Guid[0]).Contains(x.ID)))
    {
        @proj.Name <br />
    }
</fieldset>

@*// profiles chooser*@
<fieldset class="chosenFields">
    <legend>Profiler</legend>

    @foreach (Profile prof in Profiles.Where(x => (MatchMake.Profiles ?? new Guid[0]).Contains(x.ID)))
    {
        @prof.Name <br />
    }

</fieldset>

@*// buyers*@
<fieldset class="chosenFields">
    <legend>Købere</legend>
    @MatchMake.Buyers
</fieldset>

@*// funds chooser *@
<fieldset class="chosenFields">
    <legend>Puljer og fonde</legend>

    @foreach (Fund fun in Funds.Where(x => (MatchMake.Funds ?? new Guid[0]).Contains(x.ID)))
    {

        @fun.Name <br />
    }
</fieldset>

@* // funds comments*@
<fieldset class="chosenFields"><legend>Ved "øvrige fonde", hvilken fond?</legend>@MatchMake.FundsText </fieldset>

@*// funds chooser *@
<fieldset class="chosenFields">
    <legend>Anden Finansiering</legend>

    @foreach (Fund fun in Funds.Where(x => (x.Type.Equals("Anden finansiering")) && (MatchMake.OtherFinancing ?? new Guid[0]).Contains(x.ID)))
    {
        @fun.Name <br />
    }
</fieldset>
<br />
@if (MatchMake.Partners.Count() > 0)
{
    <fieldset class="chosenFields">
        <legend>Samarbejdspartner information</legend>
        @*// Matchmaking Partner*@
        @if(PartnerTypes.Count>0){
        <fieldset class="chosenFields">
            <legend>Samarbejdspartner</legend>

            @foreach (MatchmakingPartnerType pt in PartnerTypes.OrderBy(x => x.Name))
            {
                if (Partner != null)
                {
                    if (pt.ID == Partner.Type)
                    {
                @pt.Name <br />
                    }

                }
            }
        </fieldset>
        }

        @* // PD comments*@
        @if (Partner.ProductDevelopmentText != null && Partner.ProductDevelopmentText != "")
        {
            <fieldset class="chosenFields">
                <legend>Produkt udvikling</legend>
                @if (Partner != null)
                {
                    @Partner.ProductDevelopmentText
                }
            </fieldset>
        }

@*// test comments*@
        @if (Partner.TestText != null && Partner.TestText != "")
        {
            <fieldset class="chosenFields">
                <legend>Test</legend>

                @if (Partner != null)
                {
                    @Partner.TestText
                }
            </fieldset>
        }

@*// sales comments*@
        @if (Partner.SalesText != null && Partner.SalesText != "")
        {
            <fieldset class="chosenFields">
                <legend>Salg</legend>

                @if (Partner != null)
                {
                    @Partner.SalesText
                }
            </fieldset>
        }

@*// other comments*@
        @if (Partner.OtherText != null && Partner.OtherText != "")
        {
            <fieldset class="chosenFields">
                <legend>Andet</legend>
                @if (Partner != null)
                {
                    @Partner.OtherText
                }
            </fieldset>
        }
    </fieldset>
}
@*// Other*@
<fieldset class="chosenFields">
    <legend>Andre kommentarer</legend>
    @MatchMake.Comments
</fieldset>


